import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { AdQuery, AdPageVO, AdForm } from "./types";
import { UserForm, UserInfo, UserPageVO, UserQuery } from "../user/types";

export function getAdPage(
  queryParams: AdQuery
): AxiosPromise<PageResult<AdPageVO[]>> {
  return request({
    url: "/api/car/ad/page",
    method: "get",
    params: queryParams,
  });
}

export function updateAd(data: AdForm) {
  return request({
    url: "/api/car/ad/updateAd",
    method: "put",
    data: data,
  });
}

export function getCarUserPage(
  queryParams: UserQuery
): AxiosPromise<PageResult<UserPageVO[]>> {
  return request({
    url: "/api/car/users/page",
    method: "get",
    params: queryParams,
  });
}
/**
 * 删除广告
 *
 * @param ids
 */
export function deleteAd(ids: string) {
  return request({
    url: "/api/car/ad/" + ids,
    method: "delete",
  });
}

/**
 * 下载APP用户导入模板
 *
 * @returns
 */
export function downloadTemplateAppApi() {
  return request({
    url: "/api/car/ad/templateAd",
    method: "get",
    responseType: "arraybuffer",
  });
}

/**
 * 导出APP用户
 *
 * @param 导出APP用户
 * @returns
 */
export function exportAd(queryParams: AdQuery) {
  return request({
    url: "/api/car/ad/expAd",
    method: "get",
    params: queryParams,
    responseType: "arraybuffer",
  });
}
